import Vue from 'vue'
import Composite from '@/common/CompositePure'
import { UPDATE_POSTER } from '@/store/mutation-types'

Vue.prototype.$createPoster = async function () {
  const { my, poster } = this.$store.state
  if (!poster) {
    const { saveImage } = await (new Composite()).compose({
      assets: [{
        name: 'pic',
        url: my.photo
      }],
      content: my.content,
      from: my.nickname
    })
    this.$store.commit(UPDATE_POSTER, saveImage)
  }
  return this.$store.state.poster
}
